from pydicom import dcmread
import matplotlib.pyplot as plt
from matplotlib import font_manager
import numpy as np

my_font = font_manager.FontProperties(fname="C:/Windows/Fonts/simsun.ttc")
im = dcmread("./../experiment_fig/CT000009")
pixel_array = im.pixel_array  # [-2000,3044]
pixel_sub_array = np.clip(pixel_array, 0, 3044)
plt.subplot(1, 2, 1), plt.title("原始CT", fontproperties=my_font)
plt.imshow(pixel_array, cmap="gray")
plt.subplot(1, 2, 2), plt.title("变暗CT", fontproperties=my_font)
plt.imshow(pixel_sub_array, cmap="gray")
plt.show()
plt.imsave("./../experiment_fig/jpg000009.jpg", pixel_sub_array, cmap="gray")
